#include <stdio.h>
#include "ofc/DMD5.h"

int main(int argc, char *argv[])
{
  DMD5  *md1  = [DMD5 alloc];
  DMD5  *md2  = [DMD5 new  ];
  DText *str;
  DData *data;

  [md1 init :"This is a test string for MD5"]; // Init with a c-string

  str = [md1 hexdigest];               // Convert MD5 value of string to hex
  printf("MD5 digest in hex of \"This is a test string for MD5\":%s.\n", [str cstring]);
  [str free];

  [md2 update :"abcdefghijklmnopqrstuvwxyz"]; // Update the md2 with a c-string and ..
  [md2 update :"0123456789" :10];      // .. data string

  data = [md2 digest];                 // Convert MD5 result to data string
  str  = [data toBase64];              // Convert data string to base64
  printf("MD5 (in base64) of \"abcdefghijklmnopqrstuvwxyz0123456789\":%s.\n", [str cstring]);
  [str  free];
  [data free];

  [md1 free];                          // Cleanup
  [md2 free];
  
  return 0;
}

